import {join} from "path"
import {config} from 'dotenv'

const env = 'development'; 
const envPath = join(__dirname, `../../.env.${env}`);
config({path: envPath});


//类型验证(实际项目建议使用更严格的校验库如 zod)
const getConfig=():any =>({
    NODE_ENV: process.env.NODE_ENV || 'test',
    PORT: process.env.PORT || '10091',
    API_URL: process.env.API_URL || `http://localhost:${process.env.PORT || '10091'}`,
    DB_HOST: process.env.DB_HOST || 'shanghai1.zhiyu.school',
    DB_USERNAME: process.env.DB_USERNAME || 'gateway',
    DB_PASSWORD: process.env.DB_PASSWORD || "ga2025te03way03",
    DB_DATABASE: process.env.DB_DATABASE || "gateway_test",
    MQTT_SHANGHAI_HOST: process.env.MQTT_SHANGHAI_HOST || "mqtt://broker.emqx.io",
    MQTT_SUZHOU_HOST: process.env.MQTT_SUZHOU_HOST || "mqtt://mqtt.shanghai1.zhiyu.school",
    SAVE_PATH: process.env.SAVE_PATH || 'https://test.shanghai1.zhiyu.school/firmware'
});
// 导出配置对象
export const envConfig = getConfig();
